#include <iostream>
#include <fstream.h>
using namespace std;

string cmd(char komenda[MAX_PATH])
{
    FILE *fp;
    string bufor;
    char line[130];
    fp = popen(komenda, "r");
    ofstream file;
    file.open("plik.txt",ios::app);
    while ( fgets(line, sizeof line, fp))
    {
        bufor+=line;
        file<<line;
        cout<<line;
    }
    pclose(fp); 
    cout<<bufor; 
    return bufor;
}

int main()
{
char komenda[MAX_PATH];
while (1)
{
	cin.getline(komenda,255);
	cmd(komenda);
}
system("pause");
return 0;
}
